const fs = require('fs');
const ini = require('ini');
const merge = require('lodash/merge');


module.exports = (filename, done) => {
    const parsed = ini.parse(fs.readFileSync(filename, 'utf-8'));
    const environment = process.env.NODE_ENV || 'development';
    const environmentConfig = parsed[environment];
    const merged = merge(parsed.default, environmentConfig, {environment});
    done(null, merged);
};
